import React, { useState , useEffect ,createContext,useContext } from 'react';

const CountContext = createContext()

// context的 Example
function Context(){
    const count = 666;
    return (
        <div>
            父组件
            <Son title="父组件给我参数"/>
            <CountContext.Provider value={count}>
                <Counter/>
            </CountContext.Provider>
        </div>
    )
}

function Counter(){
    const count = useContext(CountContext)  //一句话就可以得到count
    return (<h2>"111"{count}</h2>)
}

function Son(props){
    console.log(props)
    return (
        <div>我是子组件
            <Counter/>
        </div>
    )
}

export default Context;